﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Yozeev.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "ABP");

            migrationBuilder.EnsureSchema(
                name: "Ticket");

            migrationBuilder.EnsureSchema(
                name: "Boat");

            migrationBuilder.EnsureSchema(
                name: "Common");

            migrationBuilder.EnsureSchema(
                name: "Basics");

            migrationBuilder.CreateTable(
                name: "Books",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(maxLength: 65, nullable: false),
                    Type = table.Column<byte>(maxLength: 65, nullable: false),
                    PublishDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    Price = table.Column<float>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Books", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "DataFileObjects",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    TenantId = table.Column<int>(nullable: true),
                    Bytes = table.Column<byte[]>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DataFileObjects", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "People",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: false),
                    EmailAddress = table.Column<string>(maxLength: 250, nullable: true),
                    Address = table.Column<string>(maxLength: 250, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_People", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "WechatAppConfigs",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    AppId = table.Column<string>(maxLength: 250, nullable: true),
                    AppSecret = table.Column<string>(maxLength: 250, nullable: true),
                    Token = table.Column<string>(maxLength: 250, nullable: true),
                    EncodingAESKey = table.Column<string>(maxLength: 500, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: true),
                    AppOrgId = table.Column<string>(maxLength: 250, nullable: true),
                    AppType = table.Column<int>(nullable: false),
                    QRCodeUrl = table.Column<string>(maxLength: 250, nullable: true),
                    TenantId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WechatAppConfigs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AuditLogs",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: true),
                    ServiceName = table.Column<string>(maxLength: 256, nullable: true),
                    MethodName = table.Column<string>(maxLength: 256, nullable: true),
                    Parameters = table.Column<string>(maxLength: 1024, nullable: true),
                    ReturnValue = table.Column<string>(nullable: true),
                    ExecutionTime = table.Column<DateTime>(nullable: false),
                    ExecutionDuration = table.Column<int>(nullable: false),
                    ClientIpAddress = table.Column<string>(maxLength: 64, nullable: true),
                    ClientName = table.Column<string>(maxLength: 128, nullable: true),
                    BrowserInfo = table.Column<string>(maxLength: 512, nullable: true),
                    Exception = table.Column<string>(maxLength: 2000, nullable: true),
                    ImpersonatorUserId = table.Column<long>(nullable: true),
                    ImpersonatorTenantId = table.Column<int>(nullable: true),
                    CustomData = table.Column<string>(maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AuditLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "BackgroundJobs",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    JobType = table.Column<string>(maxLength: 512, nullable: false),
                    JobArgs = table.Column<string>(maxLength: 1048576, nullable: false),
                    TryCount = table.Column<short>(nullable: false),
                    NextTryTime = table.Column<DateTime>(nullable: false),
                    LastTryTime = table.Column<DateTime>(nullable: true),
                    IsAbandoned = table.Column<bool>(nullable: false),
                    Priority = table.Column<byte>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BackgroundJobs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Editions",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Name = table.Column<string>(maxLength: 32, nullable: false),
                    DisplayName = table.Column<string>(maxLength: 64, nullable: false),
                    Discriminator = table.Column<string>(nullable: false),
                    ExpiringEditionId = table.Column<int>(nullable: true),
                    MonthlyPrice = table.Column<decimal>(nullable: true),
                    AnnualPrice = table.Column<decimal>(nullable: true),
                    TrialDayCount = table.Column<int>(nullable: true),
                    WaitingDayAfterExpire = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Editions", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "EntityChangeSets",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    BrowserInfo = table.Column<string>(maxLength: 512, nullable: true),
                    ClientIpAddress = table.Column<string>(maxLength: 64, nullable: true),
                    ClientName = table.Column<string>(maxLength: 128, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    ExtensionData = table.Column<string>(nullable: true),
                    ImpersonatorTenantId = table.Column<int>(nullable: true),
                    ImpersonatorUserId = table.Column<long>(nullable: true),
                    Reason = table.Column<string>(maxLength: 256, nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EntityChangeSets", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Languages",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    Name = table.Column<string>(maxLength: 10, nullable: false),
                    DisplayName = table.Column<string>(maxLength: 64, nullable: false),
                    Icon = table.Column<string>(maxLength: 128, nullable: true),
                    IsDisabled = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Languages", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LanguageTexts",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    LanguageName = table.Column<string>(maxLength: 10, nullable: false),
                    Source = table.Column<string>(maxLength: 128, nullable: false),
                    Key = table.Column<string>(maxLength: 256, nullable: false),
                    Value = table.Column<string>(maxLength: 67108864, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LanguageTexts", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Notifications",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    NotificationName = table.Column<string>(maxLength: 96, nullable: false),
                    Data = table.Column<string>(maxLength: 1048576, nullable: true),
                    DataTypeName = table.Column<string>(maxLength: 512, nullable: true),
                    EntityTypeName = table.Column<string>(maxLength: 250, nullable: true),
                    EntityTypeAssemblyQualifiedName = table.Column<string>(maxLength: 512, nullable: true),
                    EntityId = table.Column<string>(maxLength: 96, nullable: true),
                    Severity = table.Column<byte>(nullable: false),
                    UserIds = table.Column<string>(maxLength: 131072, nullable: true),
                    ExcludedUserIds = table.Column<string>(maxLength: 131072, nullable: true),
                    TenantIds = table.Column<string>(maxLength: 131072, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Notifications", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "NotificationSubscriptions",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    NotificationName = table.Column<string>(maxLength: 96, nullable: true),
                    EntityTypeName = table.Column<string>(maxLength: 250, nullable: true),
                    EntityTypeAssemblyQualifiedName = table.Column<string>(maxLength: 512, nullable: true),
                    EntityId = table.Column<string>(maxLength: 96, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NotificationSubscriptions", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "OrganizationUnitRoles",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    RoleId = table.Column<int>(nullable: false),
                    OrganizationUnitId = table.Column<long>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OrganizationUnitRoles", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "OrganizationUnits",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    ParentId = table.Column<long>(nullable: true),
                    Code = table.Column<string>(maxLength: 95, nullable: false),
                    DisplayName = table.Column<string>(maxLength: 128, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OrganizationUnits", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OrganizationUnits_OrganizationUnits_ParentId",
                        column: x => x.ParentId,
                        principalSchema: "ABP",
                        principalTable: "OrganizationUnits",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "PersistedGrants",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 200, nullable: false),
                    Type = table.Column<string>(maxLength: 50, nullable: false),
                    SubjectId = table.Column<string>(maxLength: 200, nullable: true),
                    ClientId = table.Column<string>(maxLength: 200, nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    Expiration = table.Column<DateTime>(nullable: true),
                    Data = table.Column<string>(maxLength: 50000, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PersistedGrants", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "TenantNotifications",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    NotificationName = table.Column<string>(maxLength: 96, nullable: false),
                    Data = table.Column<string>(maxLength: 1048576, nullable: true),
                    DataTypeName = table.Column<string>(maxLength: 512, nullable: true),
                    EntityTypeName = table.Column<string>(maxLength: 250, nullable: true),
                    EntityTypeAssemblyQualifiedName = table.Column<string>(maxLength: 512, nullable: true),
                    EntityId = table.Column<string>(maxLength: 96, nullable: true),
                    Severity = table.Column<byte>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TenantNotifications", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserAccounts",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    UserLinkId = table.Column<long>(nullable: true),
                    UserName = table.Column<string>(maxLength: 256, nullable: true),
                    EmailAddress = table.Column<string>(maxLength: 256, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserAccounts", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserLoginAttempts",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TenantId = table.Column<int>(nullable: true),
                    TenancyName = table.Column<string>(maxLength: 64, nullable: true),
                    UserId = table.Column<long>(nullable: true),
                    UserNameOrEmailAddress = table.Column<string>(maxLength: 255, nullable: true),
                    ClientIpAddress = table.Column<string>(maxLength: 64, nullable: true),
                    ClientName = table.Column<string>(maxLength: 128, nullable: true),
                    BrowserInfo = table.Column<string>(maxLength: 512, nullable: true),
                    Result = table.Column<byte>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserLoginAttempts", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserNotifications",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    TenantNotificationId = table.Column<Guid>(nullable: false),
                    State = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserNotifications", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserOrganizationUnits",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    OrganizationUnitId = table.Column<long>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserOrganizationUnits", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Users",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    AuthenticationSource = table.Column<string>(maxLength: 64, nullable: true),
                    UserName = table.Column<string>(maxLength: 256, nullable: false),
                    TenantId = table.Column<int>(nullable: true),
                    EmailAddress = table.Column<string>(maxLength: 256, nullable: true),
                    Password = table.Column<string>(maxLength: 128, nullable: false),
                    EmailConfirmationCode = table.Column<string>(maxLength: 328, nullable: true),
                    PasswordResetCode = table.Column<string>(maxLength: 328, nullable: true),
                    LockoutEndDateUtc = table.Column<DateTime>(nullable: true),
                    AccessFailedCount = table.Column<int>(nullable: false),
                    IsLockoutEnabled = table.Column<bool>(nullable: false),
                    PhoneNumber = table.Column<string>(maxLength: 32, nullable: true),
                    IsPhoneNumberConfirmed = table.Column<bool>(nullable: false),
                    SecurityStamp = table.Column<string>(maxLength: 128, nullable: true),
                    IsTwoFactorEnabled = table.Column<bool>(nullable: false),
                    IsEmailConfirmed = table.Column<bool>(nullable: false),
                    IsActive = table.Column<bool>(nullable: false),
                    NormalizedUserName = table.Column<string>(maxLength: 256, nullable: false),
                    NormalizedEmailAddress = table.Column<string>(maxLength: 256, nullable: false),
                    ConcurrencyStamp = table.Column<string>(maxLength: 128, nullable: true),
                    SignInToken = table.Column<string>(nullable: true),
                    NeedToChangeThePassword = table.Column<bool>(nullable: false),
                    SignInTokenExpireTimeUtc = table.Column<DateTime>(nullable: true),
                    ProfilePictureId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Users", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Users_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Users_Users_DeleterUserId",
                        column: x => x.DeleterUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Users_Users_LastModifierUserId",
                        column: x => x.LastModifierUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AppSubscriptionPayments",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Gateway = table.Column<int>(nullable: false),
                    Amount = table.Column<decimal>(nullable: false),
                    Status = table.Column<int>(nullable: false),
                    EditionId = table.Column<int>(nullable: false),
                    TenantId = table.Column<int>(nullable: false),
                    DayCount = table.Column<int>(nullable: false),
                    PaymentPeriodType = table.Column<int>(nullable: true),
                    PaymentId = table.Column<string>(nullable: true),
                    InvoiceNo = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppSubscriptionPayments", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AppSubscriptionPayments_Editions_EditionId",
                        column: x => x.EditionId,
                        principalSchema: "ABP",
                        principalTable: "Editions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Features",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    Name = table.Column<string>(maxLength: 128, nullable: false),
                    Value = table.Column<string>(maxLength: 2000, nullable: false),
                    Discriminator = table.Column<string>(nullable: false),
                    EditionId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Features", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Features_Editions_EditionId",
                        column: x => x.EditionId,
                        principalSchema: "ABP",
                        principalTable: "Editions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "EntityChanges",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ChangeTime = table.Column<DateTime>(nullable: false),
                    ChangeType = table.Column<byte>(nullable: false),
                    EntityChangeSetId = table.Column<long>(nullable: false),
                    EntityId = table.Column<string>(maxLength: 48, nullable: true),
                    EntityTypeFullName = table.Column<string>(maxLength: 192, nullable: true),
                    TenantId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EntityChanges", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EntityChanges_EntityChangeSets_EntityChangeSetId",
                        column: x => x.EntityChangeSetId,
                        principalSchema: "ABP",
                        principalTable: "EntityChangeSets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Roles",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    Name = table.Column<string>(maxLength: 32, nullable: false),
                    DisplayName = table.Column<string>(maxLength: 64, nullable: false),
                    IsStatic = table.Column<bool>(nullable: false),
                    IsDefault = table.Column<bool>(nullable: false),
                    NormalizedName = table.Column<string>(maxLength: 32, nullable: false),
                    ConcurrencyStamp = table.Column<string>(maxLength: 128, nullable: true),
                    Description = table.Column<string>(maxLength: 5000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Roles", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Roles_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Roles_Users_DeleterUserId",
                        column: x => x.DeleterUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Roles_Users_LastModifierUserId",
                        column: x => x.LastModifierUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Settings",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: true),
                    Name = table.Column<string>(maxLength: 256, nullable: false),
                    Value = table.Column<string>(maxLength: 2000, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Settings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Settings_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Tenants",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    TenancyName = table.Column<string>(maxLength: 64, nullable: false),
                    Name = table.Column<string>(maxLength: 128, nullable: false),
                    ConnectionString = table.Column<string>(maxLength: 1024, nullable: true),
                    IsActive = table.Column<bool>(nullable: false),
                    EditionId = table.Column<int>(nullable: true),
                    SubscriptionEndUtc = table.Column<DateTime>(nullable: true),
                    IsInTrialPeriod = table.Column<bool>(nullable: false),
                    CustomCssId = table.Column<Guid>(nullable: true),
                    LogoId = table.Column<Guid>(nullable: true),
                    LogoFileType = table.Column<string>(maxLength: 64, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Tenants", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Tenants_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Tenants_Users_DeleterUserId",
                        column: x => x.DeleterUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Tenants_Editions_EditionId",
                        column: x => x.EditionId,
                        principalSchema: "ABP",
                        principalTable: "Editions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Tenants_Users_LastModifierUserId",
                        column: x => x.LastModifierUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "UserClaims",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    ClaimType = table.Column<string>(maxLength: 256, nullable: true),
                    ClaimValue = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserClaims", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserClaims_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "UserLogins",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
                    ProviderKey = table.Column<string>(maxLength: 256, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserLogins", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserLogins_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "UserRoles",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    RoleId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserRoles", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserRoles_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "UserTokens",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    TenantId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: false),
                    LoginProvider = table.Column<string>(maxLength: 128, nullable: true),
                    Name = table.Column<string>(maxLength: 128, nullable: true),
                    Value = table.Column<string>(maxLength: 512, nullable: true),
                    ExpireDate = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserTokens", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserTokens_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Branchs",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    ParentId = table.Column<Guid>(maxLength: 65, nullable: true),
                    BranchCode = table.Column<string>(maxLength: 65, nullable: false),
                    BranchName = table.Column<string>(maxLength: 65, nullable: false),
                    Sort = table.Column<long>(maxLength: 65, nullable: true),
                    Level = table.Column<long>(maxLength: 65, nullable: true),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Branchs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Branchs_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Branchs_Branchs_ParentId",
                        column: x => x.ParentId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "CheckRecords",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    Mobile = table.Column<string>(maxLength: 65, nullable: false),
                    MassageType = table.Column<int>(maxLength: 65, nullable: false),
                    CheckExplain = table.Column<string>(maxLength: 65, nullable: false),
                    Captcha = table.Column<string>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false),
                    CheckTime = table.Column<DateTime>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CheckRecords", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CheckRecords_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "ClientVersions",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    AppName = table.Column<string>(maxLength: 65, nullable: false),
                    VersionName = table.Column<string>(maxLength: 65, nullable: false),
                    VersionCode = table.Column<string>(maxLength: 65, nullable: false),
                    VersionDesc = table.Column<string>(maxLength: 65, nullable: false),
                    DeviceType = table.Column<int>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ClientVersions", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ClientVersions_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "DateDictionarys",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DictionaryName = table.Column<string>(maxLength: 65, nullable: false),
                    DictionaryCode = table.Column<string>(maxLength: 65, nullable: false),
                    Sort = table.Column<long>(maxLength: 65, nullable: false),
                    ParentId = table.Column<Guid>(maxLength: 65, nullable: true),
                    Explain = table.Column<string>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DateDictionarys", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DateDictionarys_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_DateDictionarys_DateDictionarys_ParentId",
                        column: x => x.ParentId,
                        principalSchema: "Basics",
                        principalTable: "DateDictionarys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Menus",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    ParentId = table.Column<Guid>(maxLength: 65, nullable: true),
                    MenuName = table.Column<string>(maxLength: 65, nullable: false),
                    MenuCode = table.Column<string>(maxLength: 65, nullable: false),
                    NavigateUrl = table.Column<string>(maxLength: 65, nullable: false),
                    Sort = table.Column<long>(maxLength: 65, nullable: true),
                    Level = table.Column<long>(maxLength: 65, nullable: true),
                    IocName = table.Column<string>(maxLength: 65, nullable: false),
                    IocClassName = table.Column<string>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Menus", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Menus_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Menus_Menus_ParentId",
                        column: x => x.ParentId,
                        principalSchema: "Basics",
                        principalTable: "Menus",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "PayMethods",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    PayName = table.Column<string>(maxLength: 65, nullable: false),
                    PayCode = table.Column<string>(maxLength: 65, nullable: false),
                    Sort = table.Column<long>(maxLength: 65, nullable: true),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PayMethods", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PayMethods_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "EntityPropertyChanges",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    EntityChangeId = table.Column<long>(nullable: false),
                    NewValue = table.Column<string>(maxLength: 512, nullable: true),
                    OriginalValue = table.Column<string>(maxLength: 512, nullable: true),
                    PropertyName = table.Column<string>(maxLength: 96, nullable: true),
                    PropertyTypeFullName = table.Column<string>(maxLength: 192, nullable: true),
                    TenantId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EntityPropertyChanges", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EntityPropertyChanges_EntityChanges_EntityChangeId",
                        column: x => x.EntityChangeId,
                        principalSchema: "ABP",
                        principalTable: "EntityChanges",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Permissions",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    Name = table.Column<string>(maxLength: 128, nullable: false),
                    IsGranted = table.Column<bool>(nullable: false),
                    Discriminator = table.Column<string>(nullable: false),
                    RoleId = table.Column<int>(nullable: true),
                    UserId = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Permissions", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Permissions_Roles_RoleId",
                        column: x => x.RoleId,
                        principalSchema: "ABP",
                        principalTable: "Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Permissions_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RoleClaims",
                schema: "ABP",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    TenantId = table.Column<int>(nullable: true),
                    RoleId = table.Column<int>(nullable: false),
                    ClaimType = table.Column<string>(maxLength: 256, nullable: true),
                    ClaimValue = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleClaims", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RoleClaims_Roles_RoleId",
                        column: x => x.RoleId,
                        principalSchema: "ABP",
                        principalTable: "Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "BranchUsers",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(maxLength: 65, nullable: false),
                    UserId = table.Column<long>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BranchUsers", x => x.Id);
                    table.ForeignKey(
                        name: "FK_BranchUsers_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_BranchUsers_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_BranchUsers_Users_UserId",
                        column: x => x.UserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Wharfs",
                schema: "Boat",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    WharfName = table.Column<string>(maxLength: 65, nullable: false),
                    WharfNo = table.Column<string>(maxLength: 65, nullable: false),
                    WharfLeader = table.Column<string>(maxLength: 65, nullable: false),
                    LeaderMobile = table.Column<long>(maxLength: 65, nullable: false),
                    WharfPosition = table.Column<string>(maxLength: 65, nullable: false),
                    IsEenable = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Wharfs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Wharfs_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Wharfs_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Customers",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    CustomerName = table.Column<string>(maxLength: 65, nullable: false),
                    Mobile = table.Column<string>(maxLength: 65, nullable: false),
                    LoginPwd = table.Column<string>(maxLength: 65, nullable: false),
                    Sex = table.Column<int>(maxLength: 65, nullable: false),
                    Country = table.Column<string>(maxLength: 65, nullable: true),
                    Province = table.Column<string>(maxLength: 65, nullable: true),
                    City = table.Column<string>(maxLength: 65, nullable: true),
                    County = table.Column<string>(maxLength: 65, nullable: true),
                    CertificatesNum = table.Column<string>(maxLength: 65, nullable: false),
                    VerifiableType = table.Column<int>(maxLength: 65, nullable: false),
                    Job = table.Column<string>(maxLength: 65, nullable: true),
                    OpenID = table.Column<string>(maxLength: 65, nullable: true),
                    Photo = table.Column<string>(maxLength: 65, nullable: true),
                    DateOfBirth = table.Column<DateTime>(maxLength: 65, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Customers", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Customers_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Customers_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Devices",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    TicketStationId = table.Column<string>(maxLength: 65, nullable: true),
                    DeviceCode = table.Column<string>(maxLength: 65, nullable: false),
                    DeviceName = table.Column<string>(maxLength: 65, nullable: false),
                    IPAddress = table.Column<string>(maxLength: 65, nullable: true),
                    Port = table.Column<string>(maxLength: 65, nullable: true),
                    DeviceType = table.Column<int>(maxLength: 65, nullable: false),
                    SecretKey = table.Column<string>(maxLength: 65, nullable: true),
                    DeviceStatus = table.Column<int>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Devices", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Devices_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Devices_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "ScenicSpots",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ScenicSpotName = table.Column<string>(maxLength: 65, nullable: false),
                    ParentId = table.Column<Guid>(maxLength: 65, nullable: true),
                    ScenicSpotInfo = table.Column<string>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ScenicSpots", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ScenicSpots_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ScenicSpots_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ScenicSpots_ScenicSpots_ParentId",
                        column: x => x.ParentId,
                        principalSchema: "Common",
                        principalTable: "ScenicSpots",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Sources",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    SourceName = table.Column<string>(maxLength: 65, nullable: false),
                    SourceCode = table.Column<string>(maxLength: 65, nullable: false),
                    Discount = table.Column<decimal>(maxLength: 65, nullable: false, defaultValue: 1m),
                    RDiscount = table.Column<decimal>(maxLength: 65, nullable: false, defaultValue: 1m)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sources", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Sources_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Sources_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "TravelAgencys",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    TravelName = table.Column<string>(maxLength: 65, nullable: false),
                    Mobile = table.Column<string>(maxLength: 65, nullable: false),
                    Contacts = table.Column<string>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false),
                    Discount = table.Column<decimal>(maxLength: 65, nullable: false),
                    PayMethod = table.Column<int>(maxLength: 65, nullable: false),
                    TotalSum = table.Column<decimal>(maxLength: 65, nullable: false),
                    PrepaidAmount = table.Column<decimal>(maxLength: 65, nullable: false),
                    AlarmAmount = table.Column<decimal>(maxLength: 65, nullable: false),
                    UpperLimit = table.Column<long>(maxLength: 65, nullable: true),
                    Lowerlimit = table.Column<long>(maxLength: 65, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TravelAgencys", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TravelAgencys_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TravelAgencys_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "TravelTicketDetails",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    CustomerId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TravelAgencyId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ActivityTempId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ActivityTempDetailId = table.Column<Guid>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TravelTicketDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TravelTicketDetails_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TravelTicketDetails_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Accounts",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    AccountNo = table.Column<string>(maxLength: 65, nullable: false),
                    AccountDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    Quantity = table.Column<long>(maxLength: 65, nullable: false),
                    Amount = table.Column<decimal>(maxLength: 65, nullable: false),
                    AccountStatus = table.Column<int>(maxLength: 65, nullable: false),
                    CollectiorId = table.Column<long>(maxLength: 65, nullable: true),
                    CollectionTime = table.Column<DateTime>(maxLength: 65, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Accounts", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Accounts_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Accounts_Users_CollectiorId",
                        column: x => x.CollectiorId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Accounts_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Tickets",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    TicketName = table.Column<string>(maxLength: 65, nullable: false),
                    TicketCode = table.Column<string>(maxLength: 65, nullable: true),
                    TicketMode = table.Column<int>(maxLength: 65, nullable: false),
                    TicketType = table.Column<int>(maxLength: 65, nullable: false),
                    CheckMethod = table.Column<int>(maxLength: 65, nullable: false),
                    TicketClassify = table.Column<int>(maxLength: 65, nullable: false),
                    CheckNum = table.Column<long>(maxLength: 65, nullable: true),
                    EffectiveLong = table.Column<long>(maxLength: 65, nullable: true),
                    UnitPrice = table.Column<decimal>(maxLength: 65, nullable: false),
                    TicketLength = table.Column<long>(maxLength: 65, nullable: true),
                    UpperLimit = table.Column<long>(maxLength: 65, nullable: true),
                    LowerLimit = table.Column<long>(maxLength: 65, nullable: true),
                    AudioName = table.Column<string>(maxLength: 65, nullable: true),
                    AuditStatus = table.Column<int>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false),
                    Sort = table.Column<long>(maxLength: 65, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Tickets", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Tickets_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Tickets_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Powers",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    MenuId = table.Column<Guid>(maxLength: 65, nullable: false),
                    MenuPath = table.Column<string>(maxLength: 65, nullable: true),
                    PowerCode = table.Column<string>(maxLength: 65, nullable: false),
                    PowerName = table.Column<string>(maxLength: 65, nullable: false),
                    Method = table.Column<string>(maxLength: 65, nullable: true),
                    Params = table.Column<string>(maxLength: 65, nullable: true),
                    GroupName = table.Column<string>(maxLength: 65, nullable: true),
                    Sort = table.Column<long>(maxLength: 65, nullable: true),
                    IocName = table.Column<string>(maxLength: 65, nullable: true),
                    IocClassName = table.Column<string>(maxLength: 65, nullable: true),
                    Category = table.Column<int>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Powers", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Powers_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Powers_Menus_MenuId",
                        column: x => x.MenuId,
                        principalSchema: "Basics",
                        principalTable: "Menus",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Routes",
                schema: "Boat",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    RouteName = table.Column<string>(maxLength: 65, nullable: false),
                    LineCode = table.Column<long>(maxLength: 65, nullable: false),
                    LineInfo = table.Column<string>(maxLength: 65, nullable: false),
                    LineImage = table.Column<string>(maxLength: 65, nullable: false),
                    StartPosition = table.Column<string>(maxLength: 65, nullable: false),
                    StartWharfId = table.Column<Guid>(maxLength: 65, nullable: true),
                    EndPosition = table.Column<string>(maxLength: 65, nullable: false),
                    EndWharfId = table.Column<Guid>(maxLength: 65, nullable: true),
                    AuditStatus = table.Column<int>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Routes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Routes_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Routes_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Routes_Wharfs_EndWharfId",
                        column: x => x.EndWharfId,
                        principalSchema: "Boat",
                        principalTable: "Wharfs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Routes_Wharfs_StartWharfId",
                        column: x => x.StartWharfId,
                        principalSchema: "Boat",
                        principalTable: "Wharfs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "GateRecords",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    DeviceId = table.Column<Guid>(maxLength: 65, nullable: false),
                    VerifiableType = table.Column<int>(maxLength: 65, nullable: false),
                    VerifiableValue = table.Column<string>(maxLength: 65, nullable: false),
                    ReturnState = table.Column<int>(maxLength: 65, nullable: false),
                    ReturnInfo = table.Column<string>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_GateRecords", x => x.Id);
                    table.ForeignKey(
                        name: "FK_GateRecords_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_GateRecords_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_GateRecords_Devices_DeviceId",
                        column: x => x.DeviceId,
                        principalSchema: "Common",
                        principalTable: "Devices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "VerifiableSets",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    DeviceId = table.Column<Guid>(maxLength: 65, nullable: false),
                    VerifiableType = table.Column<int>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VerifiableSets", x => x.Id);
                    table.ForeignKey(
                        name: "FK_VerifiableSets_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_VerifiableSets_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_VerifiableSets_Devices_DeviceId",
                        column: x => x.DeviceId,
                        principalSchema: "Common",
                        principalTable: "Devices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TicketStations",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ScenicSpotId = table.Column<Guid>(maxLength: 65, nullable: false),
                    StationName = table.Column<string>(maxLength: 65, nullable: true),
                    Remand = table.Column<string>(maxLength: 65, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketStations", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketStations_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketStations_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketStations_ScenicSpots_ScenicSpotId",
                        column: x => x.ScenicSpotId,
                        principalSchema: "Common",
                        principalTable: "ScenicSpots",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RechargeRecords",
                schema: "Common",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    TravelAgencyId = table.Column<Guid>(maxLength: 65, nullable: false),
                    Amount = table.Column<decimal>(maxLength: 65, nullable: false),
                    RechargeStatus = table.Column<int>(maxLength: 65, nullable: false),
                    PayMethodId = table.Column<Guid>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RechargeRecords", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RechargeRecords_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_RechargeRecords_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_RechargeRecords_PayMethods_PayMethodId",
                        column: x => x.PayMethodId,
                        principalSchema: "Basics",
                        principalTable: "PayMethods",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RechargeRecords_TravelAgencys_TravelAgencyId",
                        column: x => x.TravelAgencyId,
                        principalSchema: "Common",
                        principalTable: "TravelAgencys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ActivityTemps",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ActivityNo = table.Column<string>(maxLength: 65, nullable: true),
                    SourceId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ScheduleId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ActivityDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    PlayDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    CustomerId = table.Column<Guid>(maxLength: 65, nullable: false),
                    OrderType = table.Column<int>(maxLength: 65, nullable: false),
                    PayStatus = table.Column<int>(maxLength: 65, nullable: false),
                    Buyer = table.Column<string>(maxLength: 65, nullable: true),
                    Mobile = table.Column<string>(maxLength: 65, nullable: true),
                    PayMethodId = table.Column<Guid>(maxLength: 65, nullable: false),
                    VoucherNo = table.Column<string>(maxLength: 65, nullable: true),
                    Remark = table.Column<string>(maxLength: 65, nullable: true),
                    TotalQuantity = table.Column<decimal>(maxLength: 65, nullable: false),
                    TotalAmount = table.Column<decimal>(maxLength: 65, nullable: false),
                    CollectionPwd = table.Column<string>(maxLength: 65, nullable: true),
                    Collector = table.Column<string>(nullable: true),
                    CollectionCode = table.Column<string>(maxLength: 65, nullable: true),
                    PayTime = table.Column<DateTime>(maxLength: 65, nullable: true),
                    ActivityId = table.Column<Guid>(maxLength: 65, nullable: true),
                    TravelAgencyId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ActivityTemps", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ActivityTemps_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ActivityTemps_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ActivityTemps_PayMethods_PayMethodId",
                        column: x => x.PayMethodId,
                        principalSchema: "Basics",
                        principalTable: "PayMethods",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ActivityTemps_Sources_SourceId",
                        column: x => x.SourceId,
                        principalSchema: "Common",
                        principalTable: "Sources",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ActivityTemps_TravelAgencys_TravelAgencyId",
                        column: x => x.TravelAgencyId,
                        principalSchema: "Common",
                        principalTable: "TravelAgencys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Activitys",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ActivityNo = table.Column<string>(maxLength: 65, nullable: true),
                    SourceId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ScheduleId = table.Column<Guid>(maxLength: 65, nullable: true),
                    OrgActivityId = table.Column<Guid>(maxLength: 65, nullable: true),
                    ActivityDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    PlayDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    CustomerId = table.Column<Guid>(maxLength: 65, nullable: false),
                    Buyer = table.Column<string>(maxLength: 65, nullable: true),
                    Mobile = table.Column<string>(maxLength: 65, nullable: true),
                    PayMethodId = table.Column<Guid>(maxLength: 65, nullable: false),
                    VoucherNo = table.Column<string>(maxLength: 65, nullable: true),
                    PayStatus = table.Column<int>(maxLength: 65, nullable: false),
                    ActivityType = table.Column<int>(maxLength: 65, nullable: false),
                    Remark = table.Column<string>(maxLength: 65, nullable: true),
                    IsPrint = table.Column<bool>(maxLength: 65, nullable: false),
                    Closed = table.Column<bool>(maxLength: 65, nullable: false),
                    TotalQuantity = table.Column<long>(maxLength: 65, nullable: false),
                    TotalAmount = table.Column<decimal>(maxLength: 65, nullable: false),
                    AccountsId = table.Column<Guid>(maxLength: 65, nullable: true),
                    AccountId = table.Column<Guid>(nullable: true),
                    OrderType = table.Column<int>(maxLength: 65, nullable: false),
                    TravelAgencyId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Activitys", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Activitys_Accounts_AccountId",
                        column: x => x.AccountId,
                        principalSchema: "Ticket",
                        principalTable: "Accounts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Activitys_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Activitys_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Activitys_PayMethods_PayMethodId",
                        column: x => x.PayMethodId,
                        principalSchema: "Basics",
                        principalTable: "PayMethods",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Activitys_Sources_SourceId",
                        column: x => x.SourceId,
                        principalSchema: "Common",
                        principalTable: "Sources",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Activitys_TravelAgencys_TravelAgencyId",
                        column: x => x.TravelAgencyId,
                        principalSchema: "Common",
                        principalTable: "TravelAgencys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "TicketIntroduces",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ScenicSpotId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TradeName = table.Column<string>(maxLength: 65, nullable: true),
                    TradeInfo = table.Column<string>(maxLength: 65, nullable: true),
                    Address = table.Column<string>(maxLength: 65, nullable: true),
                    CoverMap = table.Column<string>(maxLength: 65, nullable: true),
                    Abstract = table.Column<string>(maxLength: 65, nullable: true),
                    Notice = table.Column<string>(maxLength: 65, nullable: true),
                    RefundRule = table.Column<string>(maxLength: 65, nullable: true),
                    IsOnLine = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketIntroduces", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketIntroduces_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketIntroduces_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketIntroduces_ScenicSpots_ScenicSpotId",
                        column: x => x.ScenicSpotId,
                        principalSchema: "Common",
                        principalTable: "ScenicSpots",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketIntroduces_Tickets_TicketId",
                        column: x => x.TicketId,
                        principalSchema: "Ticket",
                        principalTable: "Tickets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TicketUserEnables",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    SaleUserId = table.Column<long>(maxLength: 65, nullable: false),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketUserEnables", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketUserEnables_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketUserEnables_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketUserEnables_Users_SaleUserId",
                        column: x => x.SaleUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketUserEnables_Tickets_TicketId",
                        column: x => x.TicketId,
                        principalSchema: "Ticket",
                        principalTable: "Tickets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PowerRoles",
                schema: "Basics",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    RoleId = table.Column<int>(maxLength: 65, nullable: false),
                    PowerId = table.Column<Guid>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PowerRoles", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PowerRoles_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_PowerRoles_Powers_PowerId",
                        column: x => x.PowerId,
                        principalSchema: "Basics",
                        principalTable: "Powers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PowerRoles_Roles_RoleId",
                        column: x => x.RoleId,
                        principalSchema: "ABP",
                        principalTable: "Roles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Boats",
                schema: "Boat",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    BoatName = table.Column<string>(maxLength: 65, nullable: false),
                    BoatCode = table.Column<string>(maxLength: 65, nullable: false),
                    SeatNumber = table.Column<long>(maxLength: 65, nullable: false),
                    RunStatus = table.Column<int>(maxLength: 65, nullable: false),
                    Leader = table.Column<string>(maxLength: 65, nullable: true),
                    LeaderMobile = table.Column<string>(maxLength: 65, nullable: true),
                    Picture = table.Column<string>(nullable: true),
                    AuditStatus = table.Column<int>(maxLength: 65, nullable: false),
                    RouteId = table.Column<Guid>(maxLength: 65, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Boats", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Boats_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Boats_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Boats_Routes_RouteId",
                        column: x => x.RouteId,
                        principalSchema: "Boat",
                        principalTable: "Routes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "TicketStationEnables",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    StationId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketStationEnables", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketStationEnables_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketStationEnables_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketStationEnables_TicketStations_StationId",
                        column: x => x.StationId,
                        principalSchema: "Ticket",
                        principalTable: "TicketStations",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketStationEnables_Tickets_TicketId",
                        column: x => x.TicketId,
                        principalSchema: "Ticket",
                        principalTable: "Tickets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Schedules",
                schema: "Boat",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ScheduleCode = table.Column<string>(nullable: true),
                    RouteId = table.Column<Guid>(maxLength: 65, nullable: false),
                    BoatId = table.Column<Guid>(maxLength: 65, nullable: false),
                    SaleDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    StartTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    EndTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    SeatQuantity = table.Column<long>(maxLength: 65, nullable: false),
                    SurplusQuantity = table.Column<long>(maxLength: 65, nullable: false),
                    ScheduleStatus = table.Column<int>(maxLength: 65, nullable: false),
                    AuditStatus = table.Column<int>(maxLength: 65, nullable: false),
                    CheckStartTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    CheckEndTime = table.Column<DateTime>(maxLength: 65, nullable: true),
                    ReserveQuantity = table.Column<long>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Schedules", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Schedules_Boats_BoatId",
                        column: x => x.BoatId,
                        principalSchema: "Boat",
                        principalTable: "Boats",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Schedules_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Schedules_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Schedules_Routes_RouteId",
                        column: x => x.RouteId,
                        principalSchema: "Boat",
                        principalTable: "Routes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TicketPrices",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ScheduleId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false),
                    Price = table.Column<decimal>(maxLength: 65, nullable: false),
                    Discount = table.Column<decimal>(maxLength: 65, nullable: false, defaultValue: 1m),
                    RDiscount = table.Column<decimal>(maxLength: 65, nullable: false, defaultValue: 1m),
                    UpperTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    LowerTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    Position = table.Column<int>(maxLength: 65, nullable: false),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false),
                    Sort = table.Column<long>(maxLength: 65, nullable: true),
                    TicketName = table.Column<string>(maxLength: 65, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketPrices", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketPrices_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketPrices_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketPrices_Schedules_ScheduleId",
                        column: x => x.ScheduleId,
                        principalSchema: "Boat",
                        principalTable: "Schedules",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketPrices_Tickets_TicketId",
                        column: x => x.TicketId,
                        principalSchema: "Ticket",
                        principalTable: "Tickets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TicketScheduleEnables",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ScheduleId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketScheduleEnables", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketScheduleEnables_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketScheduleEnables_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketScheduleEnables_Schedules_ScheduleId",
                        column: x => x.ScheduleId,
                        principalSchema: "Boat",
                        principalTable: "Schedules",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketScheduleEnables_Tickets_TicketId",
                        column: x => x.TicketId,
                        principalSchema: "Ticket",
                        principalTable: "Tickets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ActivityDetails",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ActivityId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketPriceId = table.Column<Guid>(maxLength: 65, nullable: false),
                    Quantity = table.Column<long>(maxLength: 65, nullable: false),
                    UnitPrice = table.Column<decimal>(maxLength: 65, nullable: false),
                    Discount = table.Column<decimal>(maxLength: 65, nullable: false),
                    SalePrice = table.Column<decimal>(maxLength: 65, nullable: false),
                    TotalAmount = table.Column<decimal>(maxLength: 65, nullable: false),
                    Remark = table.Column<string>(maxLength: 65, nullable: true),
                    AccountId = table.Column<Guid>(maxLength: 65, nullable: true),
                    AccountDetailId = table.Column<Guid>(maxLength: 65, nullable: true),
                    OrgDetailId = table.Column<Guid>(maxLength: 65, nullable: true),
                    CustomerId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ActivityDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ActivityDetails_Activitys_ActivityId",
                        column: x => x.ActivityId,
                        principalSchema: "Ticket",
                        principalTable: "Activitys",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ActivityDetails_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ActivityDetails_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ActivityDetails_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalSchema: "Common",
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ActivityDetails_TicketPrices_TicketPriceId",
                        column: x => x.TicketPriceId,
                        principalSchema: "Ticket",
                        principalTable: "TicketPrices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ActivityTempDetails",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ActivityTempId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketPriceId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketName = table.Column<string>(maxLength: 65, nullable: false),
                    SalePrice = table.Column<decimal>(maxLength: 65, nullable: false),
                    Quantity = table.Column<long>(maxLength: 65, nullable: false),
                    UniPrice = table.Column<decimal>(maxLength: 65, nullable: false),
                    Discount = table.Column<decimal>(maxLength: 65, nullable: false),
                    TotalAmount = table.Column<decimal>(nullable: false),
                    CustomerId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ActivityTempDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ActivityTempDetails_ActivityTemps_ActivityTempId",
                        column: x => x.ActivityTempId,
                        principalSchema: "Ticket",
                        principalTable: "ActivityTemps",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ActivityTempDetails_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ActivityTempDetails_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ActivityTempDetails_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalSchema: "Common",
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ActivityTempDetails_TicketPrices_TicketPriceId",
                        column: x => x.TicketPriceId,
                        principalSchema: "Ticket",
                        principalTable: "TicketPrices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "PriceAudits",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    ScheduleId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false),
                    OrgTicketPriceId = table.Column<Guid>(maxLength: 65, nullable: true),
                    IsEnabled = table.Column<bool>(maxLength: 65, nullable: false),
                    Price = table.Column<decimal>(maxLength: 65, nullable: false),
                    Discount = table.Column<decimal>(maxLength: 65, nullable: false),
                    RDiscount = table.Column<decimal>(maxLength: 65, nullable: false),
                    UpperTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    LowerTime = table.Column<DateTime>(maxLength: 65, nullable: true),
                    AuditStatus = table.Column<int>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PriceAudits", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PriceAudits_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_PriceAudits_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_PriceAudits_TicketPrices_OrgTicketPriceId",
                        column: x => x.OrgTicketPriceId,
                        principalSchema: "Ticket",
                        principalTable: "TicketPrices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_PriceAudits_Schedules_ScheduleId",
                        column: x => x.ScheduleId,
                        principalSchema: "Boat",
                        principalTable: "Schedules",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PriceAudits_Tickets_TicketId",
                        column: x => x.TicketId,
                        principalSchema: "Ticket",
                        principalTable: "Tickets",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "AccountDetails",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    AccountId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ActivityDetailId = table.Column<Guid>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AccountDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AccountDetails_Accounts_AccountId",
                        column: x => x.AccountId,
                        principalSchema: "Ticket",
                        principalTable: "Accounts",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AccountDetails_ActivityDetails_ActivityDetailId",
                        column: x => x.ActivityDetailId,
                        principalSchema: "Ticket",
                        principalTable: "ActivityDetails",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AccountDetails_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_AccountDetails_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "TicketDetails",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    TicketNo = table.Column<string>(maxLength: 65, nullable: true),
                    ActivityDetailId = table.Column<Guid>(maxLength: 65, nullable: false),
                    ActivityId = table.Column<Guid>(maxLength: 65, nullable: false),
                    OrgActivityDetailId = table.Column<Guid>(maxLength: 65, nullable: true),
                    OrgActivityId = table.Column<Guid>(maxLength: 65, nullable: true),
                    CustomerId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false),
                    QRCode = table.Column<string>(maxLength: 65, nullable: true),
                    CheckingQuantity = table.Column<long>(maxLength: 65, nullable: false),
                    CheckedQuantity = table.Column<long>(maxLength: 65, nullable: false),
                    StartDateTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    EndDateTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    CheckMethod = table.Column<int>(maxLength: 65, nullable: false),
                    RouteId = table.Column<Guid>(maxLength: 65, nullable: true),
                    ScheduleId = table.Column<Guid>(maxLength: 65, nullable: true),
                    BoatId = table.Column<Guid>(maxLength: 65, nullable: true),
                    TicketStatus = table.Column<int>(maxLength: 65, nullable: false),
                    CheckTime = table.Column<DateTime>(nullable: true),
                    IsPrint = table.Column<bool>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketDetails_ActivityDetails_ActivityDetailId",
                        column: x => x.ActivityDetailId,
                        principalSchema: "Ticket",
                        principalTable: "ActivityDetails",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketDetails_Boats_BoatId",
                        column: x => x.BoatId,
                        principalSchema: "Boat",
                        principalTable: "Boats",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketDetails_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketDetails_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketDetails_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalSchema: "Common",
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketDetails_Routes_RouteId",
                        column: x => x.RouteId,
                        principalSchema: "Boat",
                        principalTable: "Routes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketDetails_Schedules_ScheduleId",
                        column: x => x.ScheduleId,
                        principalSchema: "Boat",
                        principalTable: "Schedules",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "TicketDetailHistorys",
                schema: "Ticket",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    BranchId = table.Column<Guid>(nullable: true),
                    TicketId = table.Column<Guid>(maxLength: 65, nullable: false),
                    DeviceId = table.Column<Guid>(maxLength: 65, nullable: false),
                    DeviceName = table.Column<string>(maxLength: 65, nullable: true),
                    TicketDetailId = table.Column<Guid>(maxLength: 65, nullable: false),
                    TicketNo = table.Column<long>(maxLength: 65, nullable: false),
                    CustomerId = table.Column<Guid>(maxLength: 65, nullable: false),
                    VisitValue = table.Column<string>(maxLength: 65, nullable: true),
                    ValidationType = table.Column<string>(maxLength: 65, nullable: true),
                    TicketName = table.Column<string>(maxLength: 65, nullable: true),
                    StatusCode = table.Column<int>(maxLength: 65, nullable: false),
                    StatusText = table.Column<string>(maxLength: 65, nullable: true),
                    CheckDate = table.Column<DateTime>(maxLength: 65, nullable: false),
                    Year = table.Column<int>(maxLength: 65, nullable: false),
                    Month = table.Column<int>(maxLength: 65, nullable: false),
                    Day = table.Column<int>(maxLength: 65, nullable: false),
                    Hour = table.Column<int>(maxLength: 65, nullable: false),
                    Minute = table.Column<int>(maxLength: 65, nullable: false),
                    YearWeek = table.Column<int>(maxLength: 65, nullable: false),
                    WeekDay = table.Column<int>(maxLength: 65, nullable: false),
                    CheckTime = table.Column<DateTime>(maxLength: 65, nullable: false),
                    CheckerId = table.Column<long>(maxLength: 65, nullable: true),
                    CheckCount = table.Column<long>(maxLength: 65, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TicketDetailHistorys", x => x.Id);
                    table.ForeignKey(
                        name: "FK_TicketDetailHistorys_Branchs_BranchId",
                        column: x => x.BranchId,
                        principalSchema: "Basics",
                        principalTable: "Branchs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketDetailHistorys_Users_CheckerId",
                        column: x => x.CheckerId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketDetailHistorys_Users_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalSchema: "ABP",
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TicketDetailHistorys_Devices_DeviceId",
                        column: x => x.DeviceId,
                        principalSchema: "Common",
                        principalTable: "Devices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TicketDetailHistorys_TicketDetails_TicketDetailId",
                        column: x => x.TicketDetailId,
                        principalSchema: "Ticket",
                        principalTable: "TicketDetails",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppSubscriptionPayments_EditionId",
                table: "AppSubscriptionPayments",
                column: "EditionId");

            migrationBuilder.CreateIndex(
                name: "IX_AppSubscriptionPayments_PaymentId_Gateway",
                table: "AppSubscriptionPayments",
                columns: new[] { "PaymentId", "Gateway" });

            migrationBuilder.CreateIndex(
                name: "IX_AppSubscriptionPayments_Status_CreationTime",
                table: "AppSubscriptionPayments",
                columns: new[] { "Status", "CreationTime" });

            migrationBuilder.CreateIndex(
                name: "IX_DataFileObjects_TenantId",
                table: "DataFileObjects",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_AuditLogs_TenantId_ExecutionDuration",
                schema: "ABP",
                table: "AuditLogs",
                columns: new[] { "TenantId", "ExecutionDuration" });

            migrationBuilder.CreateIndex(
                name: "IX_AuditLogs_TenantId_ExecutionTime",
                schema: "ABP",
                table: "AuditLogs",
                columns: new[] { "TenantId", "ExecutionTime" });

            migrationBuilder.CreateIndex(
                name: "IX_AuditLogs_TenantId_UserId",
                schema: "ABP",
                table: "AuditLogs",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_BackgroundJobs_IsAbandoned_NextTryTime",
                schema: "ABP",
                table: "BackgroundJobs",
                columns: new[] { "IsAbandoned", "NextTryTime" });

            migrationBuilder.CreateIndex(
                name: "IX_EntityChanges_EntityChangeSetId",
                schema: "ABP",
                table: "EntityChanges",
                column: "EntityChangeSetId");

            migrationBuilder.CreateIndex(
                name: "IX_EntityChanges_EntityTypeFullName_EntityId",
                schema: "ABP",
                table: "EntityChanges",
                columns: new[] { "EntityTypeFullName", "EntityId" });

            migrationBuilder.CreateIndex(
                name: "IX_EntityChangeSets_TenantId_CreationTime",
                schema: "ABP",
                table: "EntityChangeSets",
                columns: new[] { "TenantId", "CreationTime" });

            migrationBuilder.CreateIndex(
                name: "IX_EntityChangeSets_TenantId_Reason",
                schema: "ABP",
                table: "EntityChangeSets",
                columns: new[] { "TenantId", "Reason" });

            migrationBuilder.CreateIndex(
                name: "IX_EntityChangeSets_TenantId_UserId",
                schema: "ABP",
                table: "EntityChangeSets",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_EntityPropertyChanges_EntityChangeId",
                schema: "ABP",
                table: "EntityPropertyChanges",
                column: "EntityChangeId");

            migrationBuilder.CreateIndex(
                name: "IX_Features_EditionId_Name",
                schema: "ABP",
                table: "Features",
                columns: new[] { "EditionId", "Name" });

            migrationBuilder.CreateIndex(
                name: "IX_Features_TenantId_Name",
                schema: "ABP",
                table: "Features",
                columns: new[] { "TenantId", "Name" });

            migrationBuilder.CreateIndex(
                name: "IX_Languages_TenantId_Name",
                schema: "ABP",
                table: "Languages",
                columns: new[] { "TenantId", "Name" });

            migrationBuilder.CreateIndex(
                name: "IX_LanguageTexts_TenantId_Source_LanguageName_Key",
                schema: "ABP",
                table: "LanguageTexts",
                columns: new[] { "TenantId", "Source", "LanguageName", "Key" });

            migrationBuilder.CreateIndex(
                name: "IX_NotificationSubscriptions_NotificationName_EntityTypeName_EntityId_UserId",
                schema: "ABP",
                table: "NotificationSubscriptions",
                columns: new[] { "NotificationName", "EntityTypeName", "EntityId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_NotificationSubscriptions_TenantId_NotificationName_EntityTypeName_EntityId_UserId",
                schema: "ABP",
                table: "NotificationSubscriptions",
                columns: new[] { "TenantId", "NotificationName", "EntityTypeName", "EntityId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_OrganizationUnitRoles_TenantId_OrganizationUnitId",
                schema: "ABP",
                table: "OrganizationUnitRoles",
                columns: new[] { "TenantId", "OrganizationUnitId" });

            migrationBuilder.CreateIndex(
                name: "IX_OrganizationUnitRoles_TenantId_RoleId",
                schema: "ABP",
                table: "OrganizationUnitRoles",
                columns: new[] { "TenantId", "RoleId" });

            migrationBuilder.CreateIndex(
                name: "IX_OrganizationUnits_ParentId",
                schema: "ABP",
                table: "OrganizationUnits",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_OrganizationUnits_TenantId_Code",
                schema: "ABP",
                table: "OrganizationUnits",
                columns: new[] { "TenantId", "Code" });

            migrationBuilder.CreateIndex(
                name: "IX_Permissions_TenantId_Name",
                schema: "ABP",
                table: "Permissions",
                columns: new[] { "TenantId", "Name" });

            migrationBuilder.CreateIndex(
                name: "IX_Permissions_RoleId",
                schema: "ABP",
                table: "Permissions",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_Permissions_UserId",
                schema: "ABP",
                table: "Permissions",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_PersistedGrants_SubjectId_ClientId_Type",
                schema: "ABP",
                table: "PersistedGrants",
                columns: new[] { "SubjectId", "ClientId", "Type" });

            migrationBuilder.CreateIndex(
                name: "IX_RoleClaims_RoleId",
                schema: "ABP",
                table: "RoleClaims",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_RoleClaims_TenantId_ClaimType",
                schema: "ABP",
                table: "RoleClaims",
                columns: new[] { "TenantId", "ClaimType" });

            migrationBuilder.CreateIndex(
                name: "IX_Roles_CreatorUserId",
                schema: "ABP",
                table: "Roles",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Roles_DeleterUserId",
                schema: "ABP",
                table: "Roles",
                column: "DeleterUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Roles_LastModifierUserId",
                schema: "ABP",
                table: "Roles",
                column: "LastModifierUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Roles_TenantId_NormalizedName",
                schema: "ABP",
                table: "Roles",
                columns: new[] { "TenantId", "NormalizedName" });

            migrationBuilder.CreateIndex(
                name: "IX_Settings_UserId",
                schema: "ABP",
                table: "Settings",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_Settings_TenantId_Name",
                schema: "ABP",
                table: "Settings",
                columns: new[] { "TenantId", "Name" });

            migrationBuilder.CreateIndex(
                name: "IX_TenantNotifications_TenantId",
                schema: "ABP",
                table: "TenantNotifications",
                column: "TenantId");

            migrationBuilder.CreateIndex(
                name: "IX_Tenants_CreationTime",
                schema: "ABP",
                table: "Tenants",
                column: "CreationTime");

            migrationBuilder.CreateIndex(
                name: "IX_Tenants_CreatorUserId",
                schema: "ABP",
                table: "Tenants",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Tenants_DeleterUserId",
                schema: "ABP",
                table: "Tenants",
                column: "DeleterUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Tenants_EditionId",
                schema: "ABP",
                table: "Tenants",
                column: "EditionId");

            migrationBuilder.CreateIndex(
                name: "IX_Tenants_LastModifierUserId",
                schema: "ABP",
                table: "Tenants",
                column: "LastModifierUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Tenants_SubscriptionEndUtc",
                schema: "ABP",
                table: "Tenants",
                column: "SubscriptionEndUtc");

            migrationBuilder.CreateIndex(
                name: "IX_Tenants_TenancyName",
                schema: "ABP",
                table: "Tenants",
                column: "TenancyName");

            migrationBuilder.CreateIndex(
                name: "IX_UserAccounts_EmailAddress",
                schema: "ABP",
                table: "UserAccounts",
                column: "EmailAddress");

            migrationBuilder.CreateIndex(
                name: "IX_UserAccounts_UserName",
                schema: "ABP",
                table: "UserAccounts",
                column: "UserName");

            migrationBuilder.CreateIndex(
                name: "IX_UserAccounts_TenantId_EmailAddress",
                schema: "ABP",
                table: "UserAccounts",
                columns: new[] { "TenantId", "EmailAddress" });

            migrationBuilder.CreateIndex(
                name: "IX_UserAccounts_TenantId_UserId",
                schema: "ABP",
                table: "UserAccounts",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_UserAccounts_TenantId_UserName",
                schema: "ABP",
                table: "UserAccounts",
                columns: new[] { "TenantId", "UserName" });

            migrationBuilder.CreateIndex(
                name: "IX_UserClaims_UserId",
                schema: "ABP",
                table: "UserClaims",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_UserClaims_TenantId_ClaimType",
                schema: "ABP",
                table: "UserClaims",
                columns: new[] { "TenantId", "ClaimType" });

            migrationBuilder.CreateIndex(
                name: "IX_UserLoginAttempts_UserId_TenantId",
                schema: "ABP",
                table: "UserLoginAttempts",
                columns: new[] { "UserId", "TenantId" });

            migrationBuilder.CreateIndex(
                name: "IX_UserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result",
                schema: "ABP",
                table: "UserLoginAttempts",
                columns: new[] { "TenancyName", "UserNameOrEmailAddress", "Result" });

            migrationBuilder.CreateIndex(
                name: "IX_UserLogins_UserId",
                schema: "ABP",
                table: "UserLogins",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_UserLogins_TenantId_UserId",
                schema: "ABP",
                table: "UserLogins",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_UserLogins_TenantId_LoginProvider_ProviderKey",
                schema: "ABP",
                table: "UserLogins",
                columns: new[] { "TenantId", "LoginProvider", "ProviderKey" });

            migrationBuilder.CreateIndex(
                name: "IX_UserNotifications_UserId_State_CreationTime",
                schema: "ABP",
                table: "UserNotifications",
                columns: new[] { "UserId", "State", "CreationTime" });

            migrationBuilder.CreateIndex(
                name: "IX_UserOrganizationUnits_TenantId_OrganizationUnitId",
                schema: "ABP",
                table: "UserOrganizationUnits",
                columns: new[] { "TenantId", "OrganizationUnitId" });

            migrationBuilder.CreateIndex(
                name: "IX_UserOrganizationUnits_TenantId_UserId",
                schema: "ABP",
                table: "UserOrganizationUnits",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_UserRoles_UserId",
                schema: "ABP",
                table: "UserRoles",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_UserRoles_TenantId_RoleId",
                schema: "ABP",
                table: "UserRoles",
                columns: new[] { "TenantId", "RoleId" });

            migrationBuilder.CreateIndex(
                name: "IX_UserRoles_TenantId_UserId",
                schema: "ABP",
                table: "UserRoles",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_Users_CreatorUserId",
                schema: "ABP",
                table: "Users",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Users_DeleterUserId",
                schema: "ABP",
                table: "Users",
                column: "DeleterUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Users_LastModifierUserId",
                schema: "ABP",
                table: "Users",
                column: "LastModifierUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Users_TenantId_NormalizedEmailAddress",
                schema: "ABP",
                table: "Users",
                columns: new[] { "TenantId", "NormalizedEmailAddress" });

            migrationBuilder.CreateIndex(
                name: "IX_Users_TenantId_NormalizedUserName",
                schema: "ABP",
                table: "Users",
                columns: new[] { "TenantId", "NormalizedUserName" });

            migrationBuilder.CreateIndex(
                name: "IX_UserTokens_UserId",
                schema: "ABP",
                table: "UserTokens",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_UserTokens_TenantId_UserId",
                schema: "ABP",
                table: "UserTokens",
                columns: new[] { "TenantId", "UserId" });

            migrationBuilder.CreateIndex(
                name: "IX_Branchs_CreatorUserId",
                schema: "Basics",
                table: "Branchs",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Branchs_ParentId",
                schema: "Basics",
                table: "Branchs",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_BranchUsers_BranchId",
                schema: "Basics",
                table: "BranchUsers",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_BranchUsers_CreatorUserId",
                schema: "Basics",
                table: "BranchUsers",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_BranchUsers_UserId",
                schema: "Basics",
                table: "BranchUsers",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_CheckRecords_CreatorUserId",
                schema: "Basics",
                table: "CheckRecords",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientVersions_CreatorUserId",
                schema: "Basics",
                table: "ClientVersions",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_DateDictionarys_CreatorUserId",
                schema: "Basics",
                table: "DateDictionarys",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_DateDictionarys_ParentId",
                schema: "Basics",
                table: "DateDictionarys",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_Menus_CreatorUserId",
                schema: "Basics",
                table: "Menus",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Menus_ParentId",
                schema: "Basics",
                table: "Menus",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_PayMethods_CreatorUserId",
                schema: "Basics",
                table: "PayMethods",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_PowerRoles_CreatorUserId",
                schema: "Basics",
                table: "PowerRoles",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_PowerRoles_PowerId",
                schema: "Basics",
                table: "PowerRoles",
                column: "PowerId");

            migrationBuilder.CreateIndex(
                name: "IX_PowerRoles_RoleId",
                schema: "Basics",
                table: "PowerRoles",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IX_Powers_CreatorUserId",
                schema: "Basics",
                table: "Powers",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Powers_MenuId",
                schema: "Basics",
                table: "Powers",
                column: "MenuId");

            migrationBuilder.CreateIndex(
                name: "IX_Boats_BranchId",
                schema: "Boat",
                table: "Boats",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Boats_CreatorUserId",
                schema: "Boat",
                table: "Boats",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Boats_RouteId",
                schema: "Boat",
                table: "Boats",
                column: "RouteId");

            migrationBuilder.CreateIndex(
                name: "IX_Routes_BranchId",
                schema: "Boat",
                table: "Routes",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Routes_CreatorUserId",
                schema: "Boat",
                table: "Routes",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Routes_EndWharfId",
                schema: "Boat",
                table: "Routes",
                column: "EndWharfId");

            migrationBuilder.CreateIndex(
                name: "IX_Routes_StartWharfId",
                schema: "Boat",
                table: "Routes",
                column: "StartWharfId");

            migrationBuilder.CreateIndex(
                name: "IX_Schedules_BoatId",
                schema: "Boat",
                table: "Schedules",
                column: "BoatId");

            migrationBuilder.CreateIndex(
                name: "IX_Schedules_BranchId",
                schema: "Boat",
                table: "Schedules",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Schedules_CreatorUserId",
                schema: "Boat",
                table: "Schedules",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Schedules_RouteId",
                schema: "Boat",
                table: "Schedules",
                column: "RouteId");

            migrationBuilder.CreateIndex(
                name: "IX_Wharfs_BranchId",
                schema: "Boat",
                table: "Wharfs",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Wharfs_CreatorUserId",
                schema: "Boat",
                table: "Wharfs",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Customers_BranchId",
                schema: "Common",
                table: "Customers",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Customers_CertificatesNum",
                schema: "Common",
                table: "Customers",
                column: "CertificatesNum",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Customers_CreatorUserId",
                schema: "Common",
                table: "Customers",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Devices_BranchId",
                schema: "Common",
                table: "Devices",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Devices_CreatorUserId",
                schema: "Common",
                table: "Devices",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_GateRecords_BranchId",
                schema: "Common",
                table: "GateRecords",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_GateRecords_CreatorUserId",
                schema: "Common",
                table: "GateRecords",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_GateRecords_DeviceId",
                schema: "Common",
                table: "GateRecords",
                column: "DeviceId");

            migrationBuilder.CreateIndex(
                name: "IX_RechargeRecords_BranchId",
                schema: "Common",
                table: "RechargeRecords",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_RechargeRecords_CreatorUserId",
                schema: "Common",
                table: "RechargeRecords",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_RechargeRecords_PayMethodId",
                schema: "Common",
                table: "RechargeRecords",
                column: "PayMethodId");

            migrationBuilder.CreateIndex(
                name: "IX_RechargeRecords_TravelAgencyId",
                schema: "Common",
                table: "RechargeRecords",
                column: "TravelAgencyId");

            migrationBuilder.CreateIndex(
                name: "IX_ScenicSpots_BranchId",
                schema: "Common",
                table: "ScenicSpots",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_ScenicSpots_CreatorUserId",
                schema: "Common",
                table: "ScenicSpots",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_ScenicSpots_ParentId",
                schema: "Common",
                table: "ScenicSpots",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_Sources_BranchId",
                schema: "Common",
                table: "Sources",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Sources_CreatorUserId",
                schema: "Common",
                table: "Sources",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TravelAgencys_BranchId",
                schema: "Common",
                table: "TravelAgencys",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TravelAgencys_CreatorUserId",
                schema: "Common",
                table: "TravelAgencys",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TravelTicketDetails_BranchId",
                schema: "Common",
                table: "TravelTicketDetails",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TravelTicketDetails_CreatorUserId",
                schema: "Common",
                table: "TravelTicketDetails",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_VerifiableSets_BranchId",
                schema: "Common",
                table: "VerifiableSets",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_VerifiableSets_CreatorUserId",
                schema: "Common",
                table: "VerifiableSets",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_VerifiableSets_DeviceId",
                schema: "Common",
                table: "VerifiableSets",
                column: "DeviceId");

            migrationBuilder.CreateIndex(
                name: "IX_AccountDetails_AccountId",
                schema: "Ticket",
                table: "AccountDetails",
                column: "AccountId");

            migrationBuilder.CreateIndex(
                name: "IX_AccountDetails_ActivityDetailId",
                schema: "Ticket",
                table: "AccountDetails",
                column: "ActivityDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_AccountDetails_BranchId",
                schema: "Ticket",
                table: "AccountDetails",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_AccountDetails_CreatorUserId",
                schema: "Ticket",
                table: "AccountDetails",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Accounts_BranchId",
                schema: "Ticket",
                table: "Accounts",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Accounts_CollectiorId",
                schema: "Ticket",
                table: "Accounts",
                column: "CollectiorId");

            migrationBuilder.CreateIndex(
                name: "IX_Accounts_CreatorUserId",
                schema: "Ticket",
                table: "Accounts",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityDetails_ActivityId",
                schema: "Ticket",
                table: "ActivityDetails",
                column: "ActivityId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityDetails_BranchId",
                schema: "Ticket",
                table: "ActivityDetails",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityDetails_CreatorUserId",
                schema: "Ticket",
                table: "ActivityDetails",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityDetails_CustomerId",
                schema: "Ticket",
                table: "ActivityDetails",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityDetails_TicketPriceId",
                schema: "Ticket",
                table: "ActivityDetails",
                column: "TicketPriceId");

            migrationBuilder.CreateIndex(
                name: "IX_Activitys_AccountId",
                schema: "Ticket",
                table: "Activitys",
                column: "AccountId");

            migrationBuilder.CreateIndex(
                name: "IX_Activitys_BranchId",
                schema: "Ticket",
                table: "Activitys",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Activitys_CreatorUserId",
                schema: "Ticket",
                table: "Activitys",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_Activitys_PayMethodId",
                schema: "Ticket",
                table: "Activitys",
                column: "PayMethodId");

            migrationBuilder.CreateIndex(
                name: "IX_Activitys_SourceId",
                schema: "Ticket",
                table: "Activitys",
                column: "SourceId");

            migrationBuilder.CreateIndex(
                name: "IX_Activitys_TravelAgencyId",
                schema: "Ticket",
                table: "Activitys",
                column: "TravelAgencyId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTempDetails_ActivityTempId",
                schema: "Ticket",
                table: "ActivityTempDetails",
                column: "ActivityTempId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTempDetails_BranchId",
                schema: "Ticket",
                table: "ActivityTempDetails",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTempDetails_CreatorUserId",
                schema: "Ticket",
                table: "ActivityTempDetails",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTempDetails_CustomerId",
                schema: "Ticket",
                table: "ActivityTempDetails",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTempDetails_TicketPriceId",
                schema: "Ticket",
                table: "ActivityTempDetails",
                column: "TicketPriceId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTemps_BranchId",
                schema: "Ticket",
                table: "ActivityTemps",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTemps_CreatorUserId",
                schema: "Ticket",
                table: "ActivityTemps",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTemps_PayMethodId",
                schema: "Ticket",
                table: "ActivityTemps",
                column: "PayMethodId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTemps_SourceId",
                schema: "Ticket",
                table: "ActivityTemps",
                column: "SourceId");

            migrationBuilder.CreateIndex(
                name: "IX_ActivityTemps_TravelAgencyId",
                schema: "Ticket",
                table: "ActivityTemps",
                column: "TravelAgencyId");

            migrationBuilder.CreateIndex(
                name: "IX_PriceAudits_BranchId",
                schema: "Ticket",
                table: "PriceAudits",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_PriceAudits_CreatorUserId",
                schema: "Ticket",
                table: "PriceAudits",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_PriceAudits_OrgTicketPriceId",
                schema: "Ticket",
                table: "PriceAudits",
                column: "OrgTicketPriceId");

            migrationBuilder.CreateIndex(
                name: "IX_PriceAudits_ScheduleId",
                schema: "Ticket",
                table: "PriceAudits",
                column: "ScheduleId");

            migrationBuilder.CreateIndex(
                name: "IX_PriceAudits_TicketId",
                schema: "Ticket",
                table: "PriceAudits",
                column: "TicketId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetailHistorys_BranchId",
                schema: "Ticket",
                table: "TicketDetailHistorys",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetailHistorys_CheckerId",
                schema: "Ticket",
                table: "TicketDetailHistorys",
                column: "CheckerId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetailHistorys_CreatorUserId",
                schema: "Ticket",
                table: "TicketDetailHistorys",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetailHistorys_DeviceId",
                schema: "Ticket",
                table: "TicketDetailHistorys",
                column: "DeviceId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetailHistorys_TicketDetailId",
                schema: "Ticket",
                table: "TicketDetailHistorys",
                column: "TicketDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetails_ActivityDetailId",
                schema: "Ticket",
                table: "TicketDetails",
                column: "ActivityDetailId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetails_BoatId",
                schema: "Ticket",
                table: "TicketDetails",
                column: "BoatId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetails_BranchId",
                schema: "Ticket",
                table: "TicketDetails",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetails_CreatorUserId",
                schema: "Ticket",
                table: "TicketDetails",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetails_CustomerId",
                schema: "Ticket",
                table: "TicketDetails",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetails_RouteId",
                schema: "Ticket",
                table: "TicketDetails",
                column: "RouteId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketDetails_ScheduleId",
                schema: "Ticket",
                table: "TicketDetails",
                column: "ScheduleId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketIntroduces_BranchId",
                schema: "Ticket",
                table: "TicketIntroduces",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketIntroduces_CreatorUserId",
                schema: "Ticket",
                table: "TicketIntroduces",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketIntroduces_ScenicSpotId",
                schema: "Ticket",
                table: "TicketIntroduces",
                column: "ScenicSpotId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketIntroduces_TicketId",
                schema: "Ticket",
                table: "TicketIntroduces",
                column: "TicketId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketPrices_BranchId",
                schema: "Ticket",
                table: "TicketPrices",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketPrices_CreatorUserId",
                schema: "Ticket",
                table: "TicketPrices",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketPrices_ScheduleId",
                schema: "Ticket",
                table: "TicketPrices",
                column: "ScheduleId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketPrices_TicketId",
                schema: "Ticket",
                table: "TicketPrices",
                column: "TicketId");

            migrationBuilder.CreateIndex(
                name: "IX_Tickets_BranchId",
                schema: "Ticket",
                table: "Tickets",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_Tickets_CreatorUserId",
                schema: "Ticket",
                table: "Tickets",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketScheduleEnables_BranchId",
                schema: "Ticket",
                table: "TicketScheduleEnables",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketScheduleEnables_CreatorUserId",
                schema: "Ticket",
                table: "TicketScheduleEnables",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketScheduleEnables_ScheduleId",
                schema: "Ticket",
                table: "TicketScheduleEnables",
                column: "ScheduleId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketScheduleEnables_TicketId",
                schema: "Ticket",
                table: "TicketScheduleEnables",
                column: "TicketId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketStationEnables_BranchId",
                schema: "Ticket",
                table: "TicketStationEnables",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketStationEnables_CreatorUserId",
                schema: "Ticket",
                table: "TicketStationEnables",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketStationEnables_StationId",
                schema: "Ticket",
                table: "TicketStationEnables",
                column: "StationId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketStationEnables_TicketId",
                schema: "Ticket",
                table: "TicketStationEnables",
                column: "TicketId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketStations_BranchId",
                schema: "Ticket",
                table: "TicketStations",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketStations_CreatorUserId",
                schema: "Ticket",
                table: "TicketStations",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketStations_ScenicSpotId",
                schema: "Ticket",
                table: "TicketStations",
                column: "ScenicSpotId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketUserEnables_BranchId",
                schema: "Ticket",
                table: "TicketUserEnables",
                column: "BranchId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketUserEnables_CreatorUserId",
                schema: "Ticket",
                table: "TicketUserEnables",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketUserEnables_SaleUserId",
                schema: "Ticket",
                table: "TicketUserEnables",
                column: "SaleUserId");

            migrationBuilder.CreateIndex(
                name: "IX_TicketUserEnables_TicketId",
                schema: "Ticket",
                table: "TicketUserEnables",
                column: "TicketId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AppSubscriptionPayments");

            migrationBuilder.DropTable(
                name: "Books");

            migrationBuilder.DropTable(
                name: "DataFileObjects");

            migrationBuilder.DropTable(
                name: "People");

            migrationBuilder.DropTable(
                name: "WechatAppConfigs");

            migrationBuilder.DropTable(
                name: "AuditLogs",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "BackgroundJobs",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "EntityPropertyChanges",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Features",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Languages",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "LanguageTexts",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Notifications",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "NotificationSubscriptions",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "OrganizationUnitRoles",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "OrganizationUnits",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Permissions",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "PersistedGrants",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "RoleClaims",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Settings",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "TenantNotifications",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Tenants",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserAccounts",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserClaims",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserLoginAttempts",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserLogins",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserNotifications",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserOrganizationUnits",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserRoles",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "UserTokens",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "BranchUsers",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "CheckRecords",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "ClientVersions",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "DateDictionarys",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "PowerRoles",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "GateRecords",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "RechargeRecords",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "TravelTicketDetails",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "VerifiableSets",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "AccountDetails",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "ActivityTempDetails",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "PriceAudits",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "TicketDetailHistorys",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "TicketIntroduces",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "TicketScheduleEnables",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "TicketStationEnables",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "TicketUserEnables",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "EntityChanges",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Editions",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Powers",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "Roles",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "ActivityTemps",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "Devices",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "TicketDetails",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "TicketStations",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "EntityChangeSets",
                schema: "ABP");

            migrationBuilder.DropTable(
                name: "Menus",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "ActivityDetails",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "ScenicSpots",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "Activitys",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "Customers",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "TicketPrices",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "Accounts",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "PayMethods",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "Sources",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "TravelAgencys",
                schema: "Common");

            migrationBuilder.DropTable(
                name: "Schedules",
                schema: "Boat");

            migrationBuilder.DropTable(
                name: "Tickets",
                schema: "Ticket");

            migrationBuilder.DropTable(
                name: "Boats",
                schema: "Boat");

            migrationBuilder.DropTable(
                name: "Routes",
                schema: "Boat");

            migrationBuilder.DropTable(
                name: "Wharfs",
                schema: "Boat");

            migrationBuilder.DropTable(
                name: "Branchs",
                schema: "Basics");

            migrationBuilder.DropTable(
                name: "Users",
                schema: "ABP");
        }
    }
}
